<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>kalman-cpp: kalman/ukf.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">kalman-cpp
   </div>
   <div id="projectbrief">Implementation of Kalman Filter in C++</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('ukf_8h_source.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">ukf.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="ukf_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160; </div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="preprocessor">#ifndef EKF_H</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="preprocessor">#define EKF_H</span></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160; </div>
<div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="ukf_8h.html#a525335710b53cb064ca56b936120431e">   29</a></span>&#160;<span class="preprocessor">#define _USE_MATH_DEFINES</span></div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;<span class="preprocessor">#include &lt;math.h&gt;</span></div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160; </div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="preprocessor">#include &lt;assert.h&gt;</span></div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="preprocessor">#include &lt;armadillo&gt;</span></div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160; </div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="keyword">using namespace </span>std;</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="keyword">using namespace </span>arma;</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160; </div>
<div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="class_u_k_f.html">   42</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_u_k_f.html">UKF</a> {</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;<span class="keyword">public</span>:  </div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;  <a class="code" href="class_u_k_f.html#aa5f9e529068a2cf933b6cc304f75f4fa">UKF</a>();</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;  </div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;  <a class="code" href="class_u_k_f.html#aebf50d27d280b3f1fb105bbe0338b0ca">~UKF</a>();</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;  </div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="class_u_k_f.html#a9a4205634f4f347511741eb69337b25b">InitSystem</a>(<span class="keywordtype">int</span> n_states, <span class="keywordtype">int</span> n_outputs, <span class="keyword">const</span> mat&amp; Q, <span class="keyword">const</span> mat&amp; R);</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;  <span class="keyword">virtual</span> colvec <a class="code" href="class_u_k_f.html#a3121b2c76798ca333cd2b292daa1a32c">f</a>(<span class="keyword">const</span> colvec &amp;x, <span class="keyword">const</span> colvec &amp;u);</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;  </div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;  <span class="keyword">virtual</span> colvec <a class="code" href="class_u_k_f.html#ae0be58f48525b8a77bfbfe0091615519">h</a>(<span class="keyword">const</span> colvec &amp;x);</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="class_u_k_f.html#ae93f8be9b388c358c65e376530f37364">InitSystemState</a>(<span class="keyword">const</span> colvec&amp; x0);</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;  </div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="class_u_k_f.html#aba92eae3369d180af50590e01a15c810">InitSystemStateCovariance</a>(<span class="keyword">const</span> mat&amp; P0);</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160; </div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="class_u_k_f.html#a548dd1501813f70f17d13d83a26ddfc1">UKalmanf</a>(<span class="keyword">const</span> colvec&amp; u);</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;  </div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="class_u_k_f.html#a548dd1501813f70f17d13d83a26ddfc1">UKalmanf</a>(<span class="keyword">const</span> colvec&amp; z, <span class="keyword">const</span> colvec&amp; u);</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;  </div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;  colvec* <a class="code" href="class_u_k_f.html#a5d73d3a72cd13d1aaa90ca776854fd75">GetCurrentState</a>();</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;  </div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;  colvec* <a class="code" href="class_u_k_f.html#a70058f98ea44a782a998612b4dde0c2e">GetCurrentOutput</a>();</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;  </div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;  colvec* <a class="code" href="class_u_k_f.html#ade927ed141ab72355141460875d3dbef">GetCurrentEstimatedState</a>();</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;  </div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;  colvec* <a class="code" href="class_u_k_f.html#a293ca62563975effafb390fce580d3bf">GetCurrentEstimatedOutput</a>();</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;  </div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160; </div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;  mat Q_;          </div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;  mat R_;          </div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;  colvec v_;       </div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;  colvec w_;       </div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;  </div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;  mat sqrt_Q_;     </div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;  mat sqrt_R_;     </div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;  </div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;  mat P_;          </div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;  colvec x_m_;     </div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;  colvec z_m_;     </div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160; </div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;<span class="keyword">protected</span>:</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;  </div>
<div class="line"><a name="l00149"></a><span class="lineno"><a class="line" href="class_u_k_f.html#a9d21d070be2cc239f6fcc7f72771fc64">  149</a></span>&#160;  <span class="keywordtype">int</span> <a class="code" href="class_u_k_f.html#a9d21d070be2cc239f6fcc7f72771fc64">nStates_</a>;   </div>
<div class="line"><a name="l00150"></a><span class="lineno"><a class="line" href="class_u_k_f.html#ad15469068a235d3474bdc6a21762183f">  150</a></span>&#160;  <span class="keywordtype">int</span> <a class="code" href="class_u_k_f.html#ad15469068a235d3474bdc6a21762183f">nOutputs_</a>;  </div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;  </div>
<div class="line"><a name="l00152"></a><span class="lineno"><a class="line" href="class_u_k_f.html#ae354cb3833947d9cac8e8a540283d913">  152</a></span>&#160;  colvec <a class="code" href="class_u_k_f.html#ae354cb3833947d9cac8e8a540283d913">x_</a>;      </div>
<div class="line"><a name="l00153"></a><span class="lineno"><a class="line" href="class_u_k_f.html#a8a0aa571ba18f83d5b507d4d0e4cc2ab">  153</a></span>&#160;  colvec <a class="code" href="class_u_k_f.html#a8a0aa571ba18f83d5b507d4d0e4cc2ab">z_</a>;      </div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;};</div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160; </div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160; </div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="ttc" id="aclass_u_k_f_html"><div class="ttname"><a href="class_u_k_f.html">UKF</a></div><div class="ttdoc">Implemetation of the Unscented Kalman filter. This class needs to be derived.</div><div class="ttdef"><b>Definition:</b> ukf.h:42</div></div>
<div class="ttc" id="aclass_u_k_f_html_a293ca62563975effafb390fce580d3bf"><div class="ttname"><a href="class_u_k_f.html#a293ca62563975effafb390fce580d3bf">UKF::GetCurrentEstimatedOutput</a></div><div class="ttdeci">colvec * GetCurrentEstimatedOutput()</div><div class="ttdoc">Get current estimated output.</div><div class="ttdef"><b>Definition:</b> ukf.cpp:229</div></div>
<div class="ttc" id="aclass_u_k_f_html_a3121b2c76798ca333cd2b292daa1a32c"><div class="ttname"><a href="class_u_k_f.html#a3121b2c76798ca333cd2b292daa1a32c">UKF::f</a></div><div class="ttdeci">virtual colvec f(const colvec &amp;x, const colvec &amp;u)</div><div class="ttdoc">Define model of your system.</div><div class="ttdef"><b>Definition:</b> ukf.cpp:57</div></div>
<div class="ttc" id="aclass_u_k_f_html_a548dd1501813f70f17d13d83a26ddfc1"><div class="ttname"><a href="class_u_k_f.html#a548dd1501813f70f17d13d83a26ddfc1">UKF::UKalmanf</a></div><div class="ttdeci">void UKalmanf(const colvec &amp;u)</div><div class="ttdoc">Do the extended Kalman iteration step-by-step while simulating the system. Simulating the system is d...</div><div class="ttdef"><b>Definition:</b> ukf.cpp:87</div></div>
<div class="ttc" id="aclass_u_k_f_html_a5d73d3a72cd13d1aaa90ca776854fd75"><div class="ttname"><a href="class_u_k_f.html#a5d73d3a72cd13d1aaa90ca776854fd75">UKF::GetCurrentState</a></div><div class="ttdeci">colvec * GetCurrentState()</div><div class="ttdoc">Get current simulated true state.</div><div class="ttdef"><b>Definition:</b> ukf.cpp:213</div></div>
<div class="ttc" id="aclass_u_k_f_html_a70058f98ea44a782a998612b4dde0c2e"><div class="ttname"><a href="class_u_k_f.html#a70058f98ea44a782a998612b4dde0c2e">UKF::GetCurrentOutput</a></div><div class="ttdeci">colvec * GetCurrentOutput()</div><div class="ttdoc">Get current simulated true output. This is analogous to the measurements.</div><div class="ttdef"><b>Definition:</b> ukf.cpp:218</div></div>
<div class="ttc" id="aclass_u_k_f_html_a8a0aa571ba18f83d5b507d4d0e4cc2ab"><div class="ttname"><a href="class_u_k_f.html#a8a0aa571ba18f83d5b507d4d0e4cc2ab">UKF::z_</a></div><div class="ttdeci">colvec z_</div><div class="ttdoc">Output matrix, by simulation, true value.</div><div class="ttdef"><b>Definition:</b> ukf.h:153</div></div>
<div class="ttc" id="aclass_u_k_f_html_a9a4205634f4f347511741eb69337b25b"><div class="ttname"><a href="class_u_k_f.html#a9a4205634f4f347511741eb69337b25b">UKF::InitSystem</a></div><div class="ttdeci">void InitSystem(int n_states, int n_outputs, const mat &amp;Q, const mat &amp;R)</div><div class="ttdoc">Tell me how many states and outputs you have!</div><div class="ttdef"><b>Definition:</b> ukf.cpp:20</div></div>
<div class="ttc" id="aclass_u_k_f_html_a9d21d070be2cc239f6fcc7f72771fc64"><div class="ttname"><a href="class_u_k_f.html#a9d21d070be2cc239f6fcc7f72771fc64">UKF::nStates_</a></div><div class="ttdeci">int nStates_</div><div class="ttdoc">Number of the states.</div><div class="ttdef"><b>Definition:</b> ukf.h:149</div></div>
<div class="ttc" id="aclass_u_k_f_html_aa5f9e529068a2cf933b6cc304f75f4fa"><div class="ttname"><a href="class_u_k_f.html#aa5f9e529068a2cf933b6cc304f75f4fa">UKF::UKF</a></div><div class="ttdeci">UKF()</div><div class="ttdoc">Constructor, nothing happens here.</div><div class="ttdef"><b>Definition:</b> ukf.cpp:10</div></div>
<div class="ttc" id="aclass_u_k_f_html_aba92eae3369d180af50590e01a15c810"><div class="ttname"><a href="class_u_k_f.html#aba92eae3369d180af50590e01a15c810">UKF::InitSystemStateCovariance</a></div><div class="ttdeci">void InitSystemStateCovariance(const mat &amp;P0)</div><div class="ttdoc">Initialize the system state covariance. Must be called after InitSystem. If not called,...</div><div class="ttdef"><b>Definition:</b> ukf.cpp:79</div></div>
<div class="ttc" id="aclass_u_k_f_html_ad15469068a235d3474bdc6a21762183f"><div class="ttname"><a href="class_u_k_f.html#ad15469068a235d3474bdc6a21762183f">UKF::nOutputs_</a></div><div class="ttdeci">int nOutputs_</div><div class="ttdoc">Number of outputs.</div><div class="ttdef"><b>Definition:</b> ukf.h:150</div></div>
<div class="ttc" id="aclass_u_k_f_html_ade927ed141ab72355141460875d3dbef"><div class="ttname"><a href="class_u_k_f.html#ade927ed141ab72355141460875d3dbef">UKF::GetCurrentEstimatedState</a></div><div class="ttdeci">colvec * GetCurrentEstimatedState()</div><div class="ttdoc">Get current estimated state. This is analogous to the filtered measurements.</div><div class="ttdef"><b>Definition:</b> ukf.cpp:223</div></div>
<div class="ttc" id="aclass_u_k_f_html_ae0be58f48525b8a77bfbfe0091615519"><div class="ttname"><a href="class_u_k_f.html#ae0be58f48525b8a77bfbfe0091615519">UKF::h</a></div><div class="ttdeci">virtual colvec h(const colvec &amp;x)</div><div class="ttdoc">Define the output model of your system.</div><div class="ttdef"><b>Definition:</b> ukf.cpp:64</div></div>
<div class="ttc" id="aclass_u_k_f_html_ae354cb3833947d9cac8e8a540283d913"><div class="ttname"><a href="class_u_k_f.html#ae354cb3833947d9cac8e8a540283d913">UKF::x_</a></div><div class="ttdeci">colvec x_</div><div class="ttdoc">State vector, by simulaiton, true value.</div><div class="ttdef"><b>Definition:</b> ukf.h:152</div></div>
<div class="ttc" id="aclass_u_k_f_html_ae93f8be9b388c358c65e376530f37364"><div class="ttname"><a href="class_u_k_f.html#ae93f8be9b388c358c65e376530f37364">UKF::InitSystemState</a></div><div class="ttdeci">void InitSystemState(const colvec &amp;x0)</div><div class="ttdoc">Initialize the system states. Must be called after InitSystem. If not called, system state is initial...</div><div class="ttdef"><b>Definition:</b> ukf.cpp:71</div></div>
<div class="ttc" id="aclass_u_k_f_html_aebf50d27d280b3f1fb105bbe0338b0ca"><div class="ttname"><a href="class_u_k_f.html#aebf50d27d280b3f1fb105bbe0338b0ca">UKF::~UKF</a></div><div class="ttdeci">~UKF()</div><div class="ttdoc">Destructur, nothing happens here.</div><div class="ttdef"><b>Definition:</b> ukf.cpp:15</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_dc133b73f91f0e3b4287924ed00a2a00.html">kalman</a></li><li class="navelem"><a class="el" href="ukf_8h.html">ukf.h</a></li>
    <li class="footer">Generated on Thu Apr 1 2021 04:15:37 for kalman-cpp by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2 </li>
  </ul>
</div>
</body>
</html>
